Ext.define("Admin.common.form.field.DicComboBox", {
	extend: "Ext.form.field.ComboBox",
	alias: "widget.dicComboBox",
	dicType: "",
	displayField: "label",
	valueField: "value",
	initComponent: function() {
		var self = this;
		Ext.apply(this, {
			storeId: "storeId_" + self.dicType,
			store: self.getStore()
		});

		this.callParent(arguments);
	},
	getStore: function() {
		if(this.store) {
			return this.store;
		}

		var data = [];
		var dictype = this.dicType;
		if(this.dicType == "incidentType") {
			data = (function() {
				var _data = [];
				for(var i = 0; i < dictList.length; i++) {
					if(dictList[i].type === "eventp") {
						_data.push(dictList[i]);
					}
				}
				return _data;
			})();
		} else if(this.dicType == "incidentStatus") {
			// data = dictList.filter(item => item.type === "emergpls");
			data = (function() {
				var _data = [];
				for(var i = 0; i < dictList.length; i++) {
					if(dictList[i].type === "emergpls") {
						_data.push(dictList[i]);
					}
				}
				return _data;
			})();
		} else if(this.dicType == 'rivername') {
			data = [{
				"label": "抚河",
				"value": "02"
			}, {
				"label": "袁河",
				"value": "03"
			}];
		} else if(this.dicType == 'riverRcd') {
			data = [{
					"river": "02",
					"value": 1,
					"label": "沙子岭-南城",
					"calriver": "沙子岭-廖坊入库"
				},
				{
					"river": "02",
					"value": 2,
					"label": "洪门坝-廖坊入库",
					"calriver": "洪门坝-廖坊入库"
				},
				{
					"river": "02",
					"value": 4,
					"label": "廖坊坝-李家渡",
					"calriver": "廖坊坝-李家渡"
				},
				{
					"river": "03",
					"value": 5,
					"label": "芦溪-分宜",
					"calriver": "芦溪-分宜"
				},
				{
					"river": "03",
					"value": 6,
					"label": "江口水库-荷湖馆",
					"calriver": "江口水库-荷湖馆"
				}
			];
		} else if(this.dicType == "jclx") {
			data = [{
					label: "流量",
					value: "ll"
				},
				{
					label: "水位",
					value: "sw"
				},
				{
					label: "水质",
					value: "sz"
				}
			];
		} else if(this.dicType == "dmmc") {
			data = [{
				label: "廖坊",
				value: "lf"
			}, {
				label: "礁石",
				value: "js"
			}];
		} else if(this.dicType == "hslx") {
			data = (function() {
				var _data = [];
				for(var i = 0; i < dictList.length; i++) {
					if(dictList[i].type === "contype") {
						_data.push(dictList[i]);
					}
				}
				return _data;
			})();
		} else if(this.dicType == "knotype") {
			data = (function() {
				var _data = [];
				for(var i = 0; i < dictList.length; i++) {
					if(dictList[i].type === "knotype") {
						_data.push(dictList[i]);
					}
				}
				return _data;
			})();
		} else if(this.dicType == "yxfa") {
			data = [{
					label: "专家综合评分法",
					value: "001"
				},
				{
					label: "综合指标法",
					value: "002"
				}
			];
		} else if(this.dicType == "daType") {
			//污染物类型
			data = (function() {
				var _data = [];
				for(var i = 0; i < dictList.length; i++) {
					if(dictList[i].type === "datype") {
						_data.push(dictList[i]);
					}
				}
				return _data;
			})();
		} else if(this.dicType == "dispositionType") {
			//处置状态
			data = (function() {
				var _data = [];
				for(var i = 0; i < dictList.length; i++) {
					if(dictList[i].type === "emergpls") {
						_data.push(dictList[i]);
					}
				}
				return _data;
			})();
		} else if(this.dicType == "method") {
			//溯源方式
			data = (function() {
				var _data = [];
				for(var i = 0; i < dictList.length; i++) {
					if(dictList[i].type === "sourcemethod") {
						_data.push(dictList[i]);
					}
				}
				return _data;
			})();
		} else {
			data = (function(dictype) {
				var _data = [];
				for(var i = 0; i < dictList.length; i++) {
					if(dictList[i].type === dictype) {
						_data.push(dictList[i]);
					}
				}
				return _data;
			})();
		}

		var store = Ext.StoreMgr.get(this.storeId);
		var fields = [{
			name: "label"
		}, {
			name: "value"
		}];
		if(store == null) {
			store = Ext.create("Ext.data.Store", {
				fields: fields,
				data: data
			});
		}
		return store;
	}
});
